<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/detail/default.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/detail/component.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css"/>
		
	</head>
	<body>
		
		<div class="am-g">
			 {include file='../Common/hy_header.html'}
		<div class="am-fl am-cf">
			<p><span id="timeout" style="color:red;font-size:30px;">{$timeoutReal}</span>秒后刷新</p>
		<p style="font-size:20px;">2分钟前的浏览量:<strong style="font-size:25px;color:#0e90d2"> {$pv|default:'0'} </strong>
		登陆量:<strong style="font-size:25px;color:#0e90d2"> {$uv|default:'0'} </strong></p>
          <div class="am-btn-toolbar am-fl">
            <div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="cleanDigestPool()" id="pass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 清空加精池</a>
            </div>
			<div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="addDigestPool()" id="Nopass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 一键添加至实时审核</a>
            </div>
			<div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="updateDigestPool()" id="status_html" class="am-btn am-btn-default hy-js-href"><span  class="am-icon-plus"></span> 勾选添加至实时审核</a>
            </div>
			<div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="refreshNow()" id="refresh_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 刷新</a>
            </div>
          </div>
        </div>
      <div class="am-g">
      <div class="am-u-sm-12">
        <div class="am-form"><table class="am-table am-table-striped am-table-hover hy-table-main">
            <thead>
              <tr>
                <th class="table-check"><input class="hy-js-selectall" type="checkbox" /></th>
                <th width="10%" class="table-type">昵称</th>
				<th width="30%" class="table-type">评论</th>
				<th width="10%" class="table-type">加精状态</th>
				<th width="20%" class="table-author">加精有效期</th>
				<th width="10%" class="table-author">加精</th>
				<th width="15%" class="table-author">操作</th>
              </tr>
          </thead>
          <tbody>
          	{foreach from=$keyword_list item=sql}
            <tr>
              <td><input class="hy-js-id" type="checkbox" name="ids" value="{$sql.id}"/></td>
              <td onClick="checkedthis(this)">{$sql.nickname}</td>
              <td onClick="checkedthis(this)">{$sql.comment|default:" - "}</td>
			  <td onClick="checkedthis(this)">{$sql.addStatusShow|default:" - "}</td>
			  <td onClick="checkedthis(this)">{$sql.EXP|date_format:"Y-m-d H:i:s"}</td>
              <td>
                    <input {if $sql.addStatus==1}checked=checked{/if} type="checkbox" onclick="addDigest({$sql.id},this)" name="addStatus">
              </td>
              <td>
                   {if $sql.addStatus==1}<a onclick="failDigest({$sql.id})">设为失效</a>{/if}
              </td>
            </tr>
             {/foreach} 
          </tbody>
        </table>
          <div class="am-cf">

  <div class="am-fr">
  {$user_list_page}
  </div>
</div>
          <hr />
      
        </div>
      </div>

    </div>
    </div>
   {include file='../Common/hy_footer.html'}
   <script>
	var digestNum = parseInt('{$digestNum}');
//  var now = parseInt('{$now}');
//	var refresh = parseInt('{$refresh}');
//	var time = parseInt('{$time}');
//	var timeout = refresh-(now-time)%refresh;
	
	var now = parseInt('{$nowReal}');
	var timestamp = parseInt('{$timestampReal}');
	var refresh = parseInt('{$refreshtimeReal}');
	var timeout = refresh-(now-timestamp)%refresh;
	$(function(){
			inter = setInterval('countDown()',1000);
	})
		function checkedthis(params){
			if($(params).parent().find("input[name=ids]").attr("checked")!="checked"){
				$(params).parent().find("input[name=ids]").prop("checked","checked");
			}else{
				$(params).parent().find("input[name=ids]").prop('checked',"");
			}
		}
		
	function countDown(){
		timeout--;
		$("#timeout").html(timeout);
		if (timeout<=0) {
			clearInterval(inter);
			window.location.href="index.php?g=admin&m=chat&a=digest";
//			window.history.go(0);
		}else{
			
		}
	}
	function refreshNow(){
		$("#refresh_html").html("<span class='am-icon-plus'></span> 刷新中...");
		parent.$('#digest').attr('src', parent.$('#digest').attr('src'));
	}
   	function addDigest(id,params){
				var url = "/ws/index.php?g=admin&m=chat&a=addDigest";
				var data={
					'id':id
				};
				$.post(url,data,function(res){
					if(res.error==0){
						window.location.href="index.php?g=admin&m=chat&a=digest";
						//window.history.go(0);
					}else{
						params.checked=false;
						alert(res.content);
					}
				},'json');
		};
	function failDigest(id){
		var url = "/ws/index.php?g=admin&m=chat&a=failDigest";
				var data={
					'id':id
				};
				$.post(url,data,function(res){
					if(res.error==0){
						window.location.href="index.php?g=admin&m=chat&a=digest";
						//window.history.go(0);
					}else{
						alert(res.content);
					}
				},'json');
	};
	function cleanDigestPool(){
		$("#pass_html").html("<span class='am-icon-plus'></span> 清理中...");
		var url ="/ws/index.php?g=admin&m=chat&a=cleanDigestPool";
		$.post(url,"",function(res){
			if(res.error==0){
				window.location.href="index.php?g=admin&m=chat&a=digest";
				//window.history.go(0);
			}else{
				alert(res.content);
			}
			$("#pass_html").html("<span class='am-icon-plus'></span>  清空加精池");
		},'json')
	}
	function addDigestPool(){
		$("#Nopass_html").html("<span class='am-icon-plus'></span> 一键添加中...");
		var url ="/ws/index.php?g=admin&m=chat&a=addDigestPool";
		$.post(url,"",function(res){
			if(res.error==0){
				//window.history.go(0);
				alert(res.content);
			}else{
				alert(res.content);
			}
		$("#Nopass_html").html("<span class='am-icon-plus'></span> 一键添加至实时审核");
		},'json')
	}
	function updateDigestPool(){
		$("#status_html").html("<span class='am-icon-plus'></span> 勾选添加中...");
		var uids = "";
		if ($("input[name='ids']:checked").length > 0) {
			if($("input[name='ids']:checked").length > digestNum){
				$("#status_html").html("<span class='am-icon-plus'></span> 勾选添加至实时审核");
				alert("加精池数量最多为"+digestNum+"，请重新勾选");
				return;
			}
			$("input[name='ids']:checked").each(function() {
				uids += "," + $(this).val();
			})
			uids = uids.substring(1);
		} else {
			$("#status_html").html("<span class='am-icon-plus'></span> 勾选添加至实时审核");
			alert("请勾选需要添加至实时审核的数据");
			return;
		}
		var url ="/ws/index.php?g=admin&m=chat&a=updateDigestPool";
		var data ={
			"uids":uids
		}
		$.post(url,data,function(res){
			if(res.error==0){
				//window.history.go(0);
				alert(res.content);
			}else{
				alert(res.content);
			}
		$("#status_html").html("<span class='am-icon-plus'></span> 勾选添加至实时审核");
		},'json')
	}
   </script>
	</body>
</html>
